package com.haoxi.gateway.test.message;

/**
 * Title:CMPP3.0,200409
 * */

import com.haoxi.gateway.test.CMPPConstant;
import com.haoxi.gateway.test.util.TypeConvert;

/**
 * 发送ActiveTestRep消息到移动网关,实现CMPP3.0 CMPP_Active_Test_REP
 */
public class CMPP30ActiveTestRep extends CMPPMessage {
    public CMPP30ActiveTestRep(int sequenceID, int success_Id)
            throws IllegalArgumentException {
        int len = 13;
        buf = new byte[len];
        TypeConvert.int2byte(len, buf, 0);
        TypeConvert.int2byte(CMPPConstant.Active_Test_Rep_Command_Id, buf, 4);
        setSequenceId(sequenceID);
        buf[12] = (byte) success_Id;

    }

    public CMPP30ActiveTestRep(byte[] buf) throws IllegalArgumentException {
        super.buf = new byte[13];
        System.arraycopy(buf, 0, super.buf, 0, 13);
        sequence_Id = TypeConvert.byte2int(super.buf, 8);
    }

    public String toString() {
        String tmpStr = "CMPP_Active_Test_REP: ";
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nMessageLength=")
                .append(getMessageLength())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nCommid=")
                .append(getCommandId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nSequence_Id=")
                .append(getSequenceId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nSuccessId=")
                .append(String.valueOf(buf[12]))));
        return tmpStr;
    }

    public int getMessageLength() {
        return TypeConvert.byte2int(buf, 0);
    }

    public int getCommandId() {
        return TypeConvert.byte2int(buf, 4);
    }

    public int getSequenceId() {
        return TypeConvert.byte2int(buf, 8);
    }

    public int getSuccessId() {
        return buf[12];
    }

}
